/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



import java.util.ArrayList;

/**
 *
 * @author Administrator
 */
public class Shop {
private ArrayList<Integer> weights;
    private ArrayList<Integer> profits;
    private ArrayList<String> names;
    private ArrayList<Item> items;
    private int noItem;
    private ArrayList<GroupOfTheSameItems> theSameTypeOfItem;

    Shop()
    {
        this.weights = new ArrayList<Integer>();
        this.profits = new ArrayList<Integer>();
        this.names = new ArrayList<String>();
        this.items = new ArrayList<Item>();
        noItem = 0;
        theSameTypeOfItem = new ArrayList<GroupOfTheSameItems>();
    }

    /**
     *
     * @param weights weight arrayList
     */
      public void setWeights(ArrayList<Integer> weights) {
        this.weights = weights;
    }

      public ArrayList<GroupOfTheSameItems> getGruopOfTheSameItem()
      {
          return theSameTypeOfItem;
      }

      /**
       * This method adds items to the shop
       * @param item Item object
       * @param no number of item
       */
    public void addItems(Item item, int no) {
        theSameTypeOfItem.add(new GroupOfTheSameItems(item, no));
        for (int i = 0; i < no; i++) {
            items.add(item);
            this.weights.add(item.getWeight());
            this.names.add(item.getName()+"-"+(i+1));
            this.profits.add(item.getProfit());
            noItem = noItem + 1;
        }
    }

/**
 * Returns all object in the shop as string
 * @return Returns all object in the shop as string
 */
    public String getAllItemInShop()
    {
        StringBuffer buff = new StringBuffer();
        for(int i =0; i<theSameTypeOfItem.size(); i++)
        {
            buff.append(theSameTypeOfItem.get(i).toString()+"\n");
        }

        return buff.toString();
    }

    /**
    public String itmesToString()
    {
        StringBuffer buff = new StringBuffer();
        for(int i=0; i<noItem;i++)
        {
            buff.append("element " + i + " name: "+ this.names.get(i) + " weight: " + weights.get(i)+ " profits: "+ profits.get(i));
            buff.append("\n");

        }
        buff.append("no items: " +noItem);
        return buff.toString();

    }
     */

/**
 * Returns weights of all items in shop
 * @return Returns weights arraylist of all items in shop
 */
    public int[] getWeight() {
        int[] weightsD = new int[weights.size()];

        int i = 0;
        for (int val : weights) {
            weightsD[i] = val;
            i++;
        }
        return weightsD;
    }

    /**
     * Returns profits of all items in shop
     * @return Returns profit of all items in shop
     */
    public int[] getProfits() {
        int[] profitsD = new int[profits.size()];

        int i = 0;
        for (int val : profits) {
            profitsD[i] = val;
            i++;
        }
        return profitsD;
    }

    /**
     * Returns names of all items in shop
     * @return Returns names of all items in shop
     */
    public String[] getNames() {
        String[] namesD = new String[names.size()];

        int i = 0;
        for (String val : names) {
            namesD[i] = val;
            i++;
        }
        return namesD;
    }
/**
 * Return number of items in shop
 * @return Return number of items in shop
 */
    public int getNoItem() {
        return this.noItem;
    }
   
}
